package com.smbms.pojo;

//import com.alibaba.fastjson.annotation.JSONField;
//import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Date;
import java.util.List;
@Data
@TableName(value = "smbms_user")
public class User {

	/* 字段 */
	@TableId(type = IdType.AUTO)
	private Integer id; // id
	@TableField("userCode")
	private String userCode; // 用户编码
	@TableField("userName")
	private String userName; // 用户名称
	@TableField("userPassword")
	private String userPassword; // 用户密码
	private Integer gender; // 性别
	//@DateTimeFormat(pattern = "yyyy-MM-dd")
	//@JSONField(format = "yyyy-MM-dd")//JSON时间转换器
	private Date birthday; // 出生日期
	private String phone; // 电话
	private String address; // 地址
	@TableField("userRole")
	private Integer userRole; // 用户角色
	@TableField("createdBy")
	private Integer createdBy; // 创建者
	//@DateTimeFormat(pattern = "yyyy-MM-dd")
	//@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	@TableField("creationDate")
	private Date creationDate; // 创建时间
	@TableField("modifyBy")
	private Integer modifyBy; // 更新者
	@TableField("modifyDate")
	private Date modifyDate; // 更新时间
	@TableField(exist = false)
	private String userRoleName; // 用户角色名称
	@TableField(exist = false)
	private Role role; // 用户角色
	@TableField(exist = false)
	private List<Address> addressList;
	@TableField("idPicPath")
	private String idPicPath;
	@TableField("workPicPath")
	private String workPicPath;
	@TableField(exist = false)
	private int age; //年龄

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
		this.age = new Date().getYear()-birthday.getYear();
	}
}
